package com.hwz.hwzliving;


import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


public class test {
    public static void main(String[] args) {
        Person a = new Person("a", 1);
        Person b = new Person("b", 2);
        Person c = new Person("c", 3);
        Person d = new Person("d", 4);
        List<Person> list = Arrays.asList(a, b, c, d);
        List<Person> collect = list.stream().filter(person -> {
            return person.getAge() >= 3;
        }).collect(Collectors.toList());
        System.out.println(collect);
    }
}

class Person{
    private String name;
    private Integer age;
    private Cat cat;

    public Person(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Cat getCat() {
        return cat;
    }

    public void setCat(Cat cat) {
        this.cat = cat;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", cat=" + cat +
                '}';
    }
}

class Cat{
    private String name;
    private Integer age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Cat(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
